package com.rockxin.cat.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.rockxin.cat.R;
import com.rockxin.cat.adapter.PlatformNoticeAdapter;
import com.rockxin.cat.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by cat on 18-3-1.
 */

public class PlatformNoticeActivity extends BaseActivity {

    @BindView(R.id.back_img)
    ImageView backImg;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.right_img)
    ImageView rightImg;
    @BindView(R.id.iv_top_bg)
    ImageView ivTopBg;
    @BindView(R.id.recyler_view)
    RecyclerView recylerView;

    private List<String> mList;
    private PlatformNoticeAdapter mAdapter;

    @Override
    protected int setLayout() {
        return R.layout.activity_platform_notice;
    }

    @Override
    public void initData() {
        initView();
        initRecyclerView();
        setListener();
        getData();
    }

    public void initView() {
        title.setText("平台公告");
        Glide.with(this).load("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg").into(ivTopBg);
    }

    private void initRecyclerView() {
        mList = new ArrayList<>();
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");
        mList.add("http://p2.wmpic.me/article/2017/02/23/1487816929_mLwPeYbD.jpg");

        mAdapter = new PlatformNoticeAdapter(R.layout.item_platform_notice, mList);
        recylerView.setAdapter(mAdapter);

        final LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
        mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recylerView.setLayoutManager(mLayoutManager);
    }

    private void setListener() {
        backImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    private void getData() {

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }
}
